# -*- coding: utf-8 -*-
# @Time    : 2024/8/30 下午7:53
# @Author  : wb
# @Email   : wb@163.com
# @File    : marking_add_template
# @Software: PyCharm

from time import sleep
from pages.wb_base_page import BasePage
from selenium.webdriver.common.by import By
class MarkingPostTemplatePage(BasePage):
    url = '/crm'
    # 定位器
    '''获取添加邮件模版按钮元素'''
    new_template_locator = (By.ID, 'add')
    '''获取编辑按钮元素'''
    template_modify_locator = (By.CSS_SELECTOR, '#form1 > div:nth-child(2) > table > tbody > tr:nth-child(1) > td:nth-child(5) > a')
    '''获取勾选框元素'''
    template_choose_locator = (By.CSS_SELECTOR, '#form1 > div:nth-child(2) > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    '''获取删除按钮元素'''
    template_delete_locator = (By.ID, 'btn_delete')

    #浏览器操作
    def click_add_post_template(self):
        # 点击添加模板
        self.driver.find_element(*self.new_template_locator).click()
        sleep(2)
    def click_modify_post_template(self):
        # 点击编辑
        self.driver.find_element(*self.template_modify_locator).click()
        sleep(2)
    def click_choose_first(self):
        # 勾选第一条数据
        self.driver.find_element(*self.template_choose_locator).click()
    def click_delete_post_template(self):
        # 点击删除
        self.driver.find_element(*self.template_delete_locator).click()
        sleep(2)
    def post_template_alert_accept(self):
        # 处理警告框
        self.driver.switch_to.alert.accept()
    sleep(3)








